if(TARGET cld3)
    return()
endif()

include(CMakeFindDependencyMacro)
find_dependency(Protobuf)

# Traditional find module variables (vcpkg polyfill)
set(cld3_INCLUDE_DIR "${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/include")
set(cld3_INCLUDE_DIRS "${cld3_INCLUDE_DIR}")
set(cld3_DIR "${cld3_INCLUDE_DIR}")

get_filename_component(_cld3_root "${CMAKE_CURRENT_LIST_FILE}" PATH)
get_filename_component(_cld3_root "${_cld3_root}" PATH)
get_filename_component(_cld3_root "${_cld3_root}" PATH)

find_library(_cld_lib NAMES cld3)
if (EXISTS "${_cld_lib}")

    add_library(cld3 INTERFACE IMPORTED GLOBAL)
    add_library(cld3::cld3 ALIAS cld3)

    target_include_directories(cld3 INTERFACE ${_cld3_root}/include)

    set(cld3_LIBRARIES "${_cld_lib}")
    target_link_libraries(cld3 INTERFACE ${cld3_LIBRARIES})
    target_link_libraries(cld3 INTERFACE ${Protobuf_LITE_LIBRARIES})

    set_property(TARGET cld3 APPEND PROPERTY IMPORTED_CONFIGURATIONS)
    set(cld3_FOUND TRUE)

else()

    set(cld3_FOUND FALSE)

endif()

unset(_cld_lib)
unset(_cld3_root)
